package cn.antsing.bean;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * spring4.3新特性
 *      1，构造函数的参数必须在ioc容器里存在
 *      2，如果有多个构造函数，必须实现默认不带参数的构造函数
 */
@Component
public class User1 {
    private ApplicationContext applicationContext;

    public User1(){

    }

    public User1(ApplicationContext applicationContext){
        this.applicationContext = applicationContext;
    }

    public User1(ApplicationContext applicationContext,User user){
        this.applicationContext = applicationContext;
    }

    public void printApplicationContext(){
        if(applicationContext != null)
        System.out.println("-----user1----:\t"+applicationContext.getClass().getName()+"\t"+applicationContext.toString());
    }
}
